home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / pbaseiv.zip / P4UTL004.TIP < prev    next >
Text File  |  1991-12-16  |  3KB  |  81 lines

  1. While running Windows 3.0 in 386 enhanced mode, there's no
  2. way to modify DOS's master copy of the environment. For
  3. example, it's not possible to change the system PATH after
  4. starting Windows. Revising the PATH from a COMMAND window or
  5. a batch file affects only that copy of the environment; the
  6. PATH settings of other windows remain unchanged.
  7.  
  8. To get around this deficiency, I wrote EDITENV.PAS [see
  9. listing] for Turbo Pascal and TurboPower Software's Object
  10. Professional. To edit an environment variable, type EDITENV
  11. <name>, where <name> is the variable in question--for
  12. example, path or lib. In order to display all variables,
  13. their settings, and the amount of unused environment space,
  14. type editenv /d.
  15.  
  16. Brian Foley
  17. Colorado Springs, Colorado
  18.  
  19. Editor's note: EDITENV's usefulness isn't limited to
  20. Windows. The program is handy for editing environment
  21. settings from DOS too. I also use it to determine how full
  22. my environment is after booting.
  23.  
  24. A copy of EDITENV.EXE is included, ready to run, in the
  25. P4UTIL directory on your PowerBase *.* Volume IV diskette.
  26. If you'd like to experiment with the source code, use the
  27. Alt-F key to extract the listing to a file. To compile, use
  28. Turbo Pascal 5.5 or 6.0 and a compatible version of Object
  29. Professional.
  30.  
  31.  
  32. EDITENV.PAS for Turbo Pascal and Object Professional edits
  33. the master environment in Windows 3.0.
  34.  
  35. ---- BEGIN LISTING ----
  36. program EditEnv;
  37. uses
  38.   OpString, OpDos, OpCrt, OpCmd, OpSEdit;
  39. var
  40.   SLE : SimpleLineEditor;
  41.   E, S : string;
  42.   Env : EnvRec;
  43. begin
  44.   E := StUpcase(ParamStr(1));
  45.   if E = '' then begin
  46.     WriteLn('Usage: EDITENV variable name');
  47.     WriteLn('       To edit variable name');
  48.     WriteLn('   Or: EDITENV /D');
  49.     WriteLn('       To display environment');
  50.     Halt;
  51.   end;
  52.   MasterEnv(Env);
  53.   if (E = '/D') or (E = '-D') then begin
  54.     DumpEnv(Env);
  55.     Halt
  56.   end;
  57.   S := GetEnvStr(Env, E);
  58.   if S = '' then begin
  59.     WriteLn('"', E, '" not found in environment');
  60.     Halt(1)
  61.   end;
  62.   SLE.Init(DefaultColorSet);
  63.   WriteLn('Current value: ', S);
  64.   SLE.ReadString('New value:     ', WhereY, 1,
  65.    127, ScreenWidth-16, S);
  66.   if (SLE.GetLastCommand <> ccQuit) then begin
  67.     WriteLn;
  68.     if SetEnvStr(Env, E, S) then
  69.       WriteLn('Environment string changed')
  70.     else
  71.       WriteLn('Unable to change environment');
  72.   end
  73. end.
  74. ---- END LISTING ----
  75.  
  76. Title: Mastering Your Environment
  77. Category: DOS
  78. Issue date: Mar 1991
  79. Editor: Tom Swan
  80. Supplementary files: P4UTIL\EDITENV.EXE
  81.